package com.byd.android.agreement.order;

import com.byd.android.agreement.BaseMessage;
import com.google.gson.JsonObject;

public class Order extends BaseMessage {
    public static final String CODE = "code";

    public static final String ORDER_MSG = "order_msg";

    public int code;

    public String clientMsg = "";

    public int getCode() {
        return code;
    }


    public void setCode(int code) {
        this.code = code;
    }

    public String getClientMsg() {
        return clientMsg;
    }

    public void setClientMsg(String clientMsg) {
        this.clientMsg = clientMsg;
    }
    //为客户端打包发送
    public static String packToJson(Order order) {
        JsonObject json = new JsonObject();
        json.addProperty(CODE, order.code);
        json.addProperty(ORDER_MSG, order.clientMsg);
        return json.toString();
    }

    //为服务器端解析
    public static Order parseJson(String Jstr) {
        Order order = new Order();
        JsonObject Jobj = mParser.parse(Jstr).getAsJsonObject();
        order.code = Jobj.get(CODE).getAsInt();
        order.clientMsg = Jobj.get(ORDER_MSG).getAsString();
        return order;
    }
}
